package com.qfedu.zf.life.mapper;

import com.qfedu.zf.life.entity.PostPage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wjw
 * @since 2024-06-20
 */
public interface PostPageMapper extends BaseMapper<PostPage> {

    //查询所有帖子
    @Select("SELECT p.id,p.user_id,p.title,p.cover_image,p.like_count,u.nickname,u.avatar" + " FROM post_page p " + "LEFT JOIN `user` u ON p.user_id = u.id")
    List<com.qfedu.zf.common.param.PostPage> getAllPosts();


    @Select("SELECT p.id,p.user_id,p.title,p.content,u.nickname,u.avatar,i.url" + " FROM post_page p " + "LEFT JOIN `user` u ON p.user_id = u.id " + "LEFT JOIN image i ON p.id = i.post_page_id " + "WHERE p.id = #{postPageId}")
    List<com.qfedu.zf.common.param.PostDetails> selectPostsDetailById(Long postPageId);


}
